﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using aier.dataaccess.model;
using Dapper;


namespace aier.dataaccess.dapper
{
    public class ScreenPropagandaDal
    {
        public DapperHelper dapperHelper { get; set; }

        /// <summary>
        /// 根据筛查ID，潜客ID查询筛查宣教信息
        /// 原程序方法：ScreeningServiceImpl-> queryPreach(String scid, String customerid)
        /// <returns></returns>
        public IEnumerable<ScreenPropagandaView> QueryPropagandaByScidAndLeadId(Guid scid,Guid leadid)
        {
            return dapperHelper.ExecueWithoutTransaction<IEnumerable<ScreenPropagandaView>>(a =>
            {
                string sql = $@"select new_propagandaId, new_lead, new_screen, new_issee, new_isorder, new_doctor, CreatedOn, CreatedBy, ModifiedOn, ModifiedBy, 
                                 new_isfollowself, new_followdoctor, new_countteardrop from new_propagandaBase p where p.new_screen='{scid}' and p.new_lead='{leadid}' ";

                SqlBuilder sqlBuilder = new SqlBuilder();
                var sqlTemplate = sqlBuilder.AddTemplate(sql);
                return a.Query<ScreenPropagandaView>(sqlTemplate.RawSql);
            });
        }
    }
}
